package com.cqfae.deploycentral.app.config;

import org.slf4j.Logger;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by JIANGLU009 on 2017/7/27.
 */
@Configuration
public class SSOMvcConfig extends WebMvcConfigurerAdapter {
/*
    private static Logger logger = LoggerFactory.getLogger(SSOMvcConfig.class);

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Autowired
    private SSOInfo sSOInfo;

    private String isOpen = "true";

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        if(StringUtils.isNotBlank(sSOInfo.getIsOpen())
                && sSOInfo.getIsOpen().equals(isOpen)){
            logger.info("===== Interceptor is open  =====");
            registry.addInterceptor(loginInterceptor)
                    .excludePathPatterns("/static/**")
                    .excludePathPatterns("/deploy-central/prod/jenkins/notify")
                    .excludePathPatterns("/deploy-central/login/getUserToken")
                    .excludePathPatterns("/deploy-central/login/logout")
                    .excludePathPatterns("/deploy-central/deploy/cleanQueue")
                    .excludePathPatterns("/deploy-central/file-sync/detail/call-back")
                    .excludePathPatterns("/deploy-central/inspect/health-check/call-back")
                    .addPathPatterns("/deploy-central/**");

        }
    }
*/
}
